-- Array Processing --

array.new .array :-
	array.new .array 8 #
array.new (ARRAY 0 .elems) .len :-
	length .elems .len #

array.length (ARRAY .len .) .len #

array.nth (ARRAY . .elems) .n .elem :-
	int .n,
	nth .elems .n .elem #
array.mnth (ARRAY . .elems) .m .n .elem :-
	mnth .elems .m .n .elem #

array.push (ARRAY .len .elems):(ARRAY .len1 .elems1) .elem :-
	let .len1 (.len + 1),
	length .elems .size, (
		.size < .len1,
		let .size1 (.size * 2),
		length .elems1 .size1,
		mnth .elems1 0 .len .elems
	;
		.elems1 = .elems
	),
	nth .elems1 .len .elem #
